package com.crm.system.controller.messageprompt;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhPageInfo;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.vo.messageprompt.MessagePromptVO;
import com.crm.system.service.messageprompt.MessagePromptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 首页消息提示-小铃铛
 * @Author lixq-f
 * @Date 2021/5/18
 * @Version V1.0
 **/
@RequestMapping("/messagePrompt")
@RestController
public class MessagePromptController {

    @Autowired
    private MessagePromptService messagePromptService;



    /**
     * @Description: 获取消息列表
     * @Param: [pageIndex, pageSize]
     * @Return: com.crm.common.model.DataResponse
     * @Author: lixq-f
     * @Date: 2021/5/18
    **/
    @PostMapping("/getMessagePromptList")
    public DataResponse selectMemberShipCardList(@RequestParam(value = "pageIndex",required = false, defaultValue = "1") Integer pageIndex,
                                                 @RequestParam(value = "pageSize", required = false, defaultValue = "5") Integer pageSize
    ){
        DhPageInfo<MessagePromptVO> pageInfo = messagePromptService.queryMessagePromptList(pageIndex, pageSize);
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),pageInfo);
    }


    /**
     * @Description: 更新消息状态为已读
     * @Param: [messageId]
     * @Return: com.crm.common.model.DataResponse
     * @Author: lixq-f
     * @Date: 2021/5/18
    **/
    @PostMapping("/updateMessageState")
    public DataResponse updateMessageState(@RequestParam("messageId") String messageId) {
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(), messagePromptService.updateMessageState(messageId));
    }


    /**
     * @Description: 未读消息数
     * @Param: []
     * @Return: java.lang.Integer
     * @Author: lixq-f
     * @Date: 2021/5/18
     **/
    @GetMapping("/unreadMessageCount")
    public DataResponse unreadMessageCount() {
        return new DhResponse(ResponseCodeEnum.OK.getResponseCode(), messagePromptService.unreadMessageCount());
    }




}
